﻿using System;
using System.Data;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using BLL;

public partial class Week_ModifyWeekRemind : System.Web.UI.Page
{
    Model.UserInfo objUserInfo = new Model.UserInfo();
    Week_RemindofManager dllWeek_RemindofManager = new Week_RemindofManager();
    protected void Page_Load(object sender, EventArgs e)
    {
        if (!IsPostBack)
        {
            //BindDropDownList(this.drpDepartment);
            bindGridView();
        }
    }

    void BindDropDownList(DropDownList _drp)
    {
        //部门绑定
        //if (_drp.Equals(this.drpDepartment))
        //{
        //    this.drpDepartment.DataSource = new BLL.DepartmentInfoManager().getNoTree();
        //    this.drpDepartment.DataTextField = "DepartmentName";
        //    this.drpDepartment.DataValueField = "DepartmentId";
        //    this.drpDepartment.DataBind();
        //    ListItem _li = new ListItem("请选择部门");
        //    this.drpDepartment.Items.Insert(0, _li);
        //    object[] _value = new object[1];
        //    _value[0] = objUserInfo.UserName;
        //    DataTable _userTable = new BLL.DepartmentInfoManager().get(UserInfoManager.field.UserName.ToString(), _value);
        //    if (_userTable.Rows.Count > 0)
        //    {
        //        this.drpDepartment.SelectedIndex = this.drpDepartment.Items.IndexOf(this.drpDepartment.Items.FindByText(_userTable.Rows[0]["DepartmentId"].ToString()));

        //    }
        //    if (Request.QueryString["depart"] != null)
        //    {
        //        this.drpDepartment.SelectedIndex = this.drpDepartment.Items.IndexOf(this.drpDepartment.Items.FindByValue(Request.QueryString["depart"].ToString()));
        //    }
        //}
    }

    /// <summary>
    /// 绑定GridView
    /// </summary>
    void bindGridView()
    {
        int WeekRemindId = Utility.HttpHelp.getParamsInt("Id");
        object[] _value = new object[1];
        _value[0] = WeekRemindId;
        DataTable dt = new BLL.Week_RemindofManager().get(BLL.Week_RemindofManager.field.RemindId.ToString(),
 _value);
        if (dt.Rows.Count > 0)
        {
            this.txtSponsor.Value = dt.Rows[0]["PlanSponsor"].ToString();
            this.txtRemindPeople.Value = dt.Rows[0]["RemindPeople"].ToString();
            this.txtTheWeekRemind.Text = dt.Rows[0]["TheWeekRemind"].ToString();
            this.txtEndDate.Text = Convert.ToDateTime(dt.Rows[0]["EndDate"].ToString()).ToShortDateString();
            //this.drpDepartment.SelectedIndex = this.drpDepartment.Items.IndexOf(this.drpDepartment.Items.FindByText(dt.Rows[0]["DepartmentName"].ToString()));
        }
    }



    protected void btnOK_Click(object sender, EventArgs e)
    {
        object[] _value = new object[5];
        _value[0] = Utility.HttpHelp.getParamsInt("Id");
        _value[1] = this.txtSponsor.Value;
        //_value[2] = this.drpDepartment.SelectedItem.Text;
        _value[2] = this.txtTheWeekRemind.Text;
        _value[3] = this.txtRemindPeople.Value;
        _value[4] = Convert.ToDateTime(this.txtEndDate.Text);
        int val = new BLL.Week_RemindofManager().edit(BLL.Week_RemindofManager.field.RemindId.ToString(), _value);
        if (val > 0)
        {
            string url = Utility.HttpHelp.getParamsString("url") + "?depart=" + Utility.HttpHelp.getParamsString("Depart") + "&MonthDate=" + Utility.HttpHelp.getParamsString("MonthDate") + "&Year=" + Utility.HttpHelp.getParamsString("Year") + "&QuarterDate=" + Utility.HttpHelp.getParamsString("QuarterDate") + "&WeekDate=" + Utility.HttpHelp.getParamsString("WeekDate");
            Utility.HttpHelp.closeWindow(url, this.Page);
        }
    }
}
